<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
	<script src="../../../jquery.tmpl.js" type="text/javascript"></script>
	<link href="../../resources/demos.css" rel="stylesheet" type="text/css" />

	<link href="../../resources/movielist.css" rel="stylesheet" type="text/css" />
</head>
<body>
<a href="../../step-by-step.html">Home</a><br />
<a href="6_hierarchical-data-source.html">Source</a>

<h3>Demo: Using {{tmpl}} to render hierarchical data.</h3>

<!--=================== Demo Section ===================-->

<script id="movieTemplate" type="text/x-jquery-tmpl">
	<tr>
		<td>${Title}</td>
		<td>
			{{tmpl(Languages) "#languageTemplate"}}
		</td>
	</tr>
</script>

<script id="languageTemplate" type="text/x-jquery-tmpl">
	<div>
		<em>${Name}</em>
	</div>
</script>

<table><tbody class="header"><tr><th>Title</th><th>Languages</th></tr></tbody>
	<tbody id="movieList"></tbody>
</table>

<script type="text/javascript">

	var movies = [
		{
			Title: "Meet Joe Black",
			Languages: [
				{ Name: "English" },
				{ Name: "French" }
			]
		},
		{
			Title: "Eyes Wide Shut",
			Languages: [
				{ Name: "French" },
				{ Name: "German" },
				{ Name: "Spanish" }
			]
		}
	];

	$( "#movieTemplate" ).tmpl( movies )
		.appendTo( "#movieList" );

</script>

<!--================ End of Demo Section ================-->

</body>
</html>


